/**
 * 
 */
package br.odb.libscene;

/**
 * @author monty
 *
 */
public class Door {
	public Mesh getMesh() {
		return mesh;
	}

	public void setMesh(Mesh mesh) {
		this.mesh = mesh;
	}

	public boolean isOpen() {
		return open;
	}

	public void setOpen(boolean open) {
		this.open = open;
	}

	public int getSector() {
		return sector;
	}

	public void setSector(int sector) {
		this.sector = sector;
	}

	private Mesh mesh;
	private boolean open;
	private int sector;
	private Door linkedDoor;
	
	public Door( int sector ) {
		this.sector = sector;
		open = false;
		mesh = null;
	}

	public void open() {
		openNonMutual();
		System.out.println("opening non-mutual");
		if ( linkedDoor != null ) {
			System.out.println("opening linked non-mutual");
			linkedDoor.openNonMutual();
		}
		
	}
	
	private void openNonMutual() {
		
		
		open = true;
		
		if ( mesh != null )
			mesh.setVisibility( false );
	}

	public void close() {
		
		
		if ( mesh != null )
			mesh.setVisibility( true );
		
		open = false;
	}

	/**
	 * @return the linkedDoor
	 */
	public Door getLinkedDoor() {
		return linkedDoor;
	}

	/**
	 * @param linkedDoor the linkedDoor to set
	 */
	public void setLinkedDoor(Door linkedDoor) {
		this.linkedDoor = linkedDoor;
	}

}
